import multiprocessing as mp
import time

_flask_dict = {}    # flask框架接收到的状态标志位

def setVisualControlHandel(flask_dict):
    global _flask_dict
    _flask_dict = flask_dict
    _flask_dict["任务一"] = False

    print(flask_dict)

def run1(flask_dict):
    setVisualControlHandel(flask_dict)
    i = 0
    while True:
        i += 1
        time.sleep(1)
        _flask_dict["任务一"] = i
        print("run1:", flask_dict)

def run2(flask_dict):
    flask_dict["任务二"] = True
    while True:
        time.sleep(1)
        print("run2:", flask_dict)

def run3(flask_dict):
    flask_dict["任务三"] = True
    while True:
        time.sleep(1)
        print("run3:", flask_dict)


if __name__ == "__main__":
    flask_dict = mp.Manager().dict({"wq": True})

    flask_dict["任务一"] = True
    flask_dict["任务二"] = False

    setVisualControlHandel(flask_dict)

    p_video = mp.Process(target=run1, args=(flask_dict,))
    p_cardev = mp.Process(target=run2, args=(flask_dict,))
    p_run3 = mp.Process(target=run3, args=(flask_dict,))

    p_run3.start()
    p_video.start()
    p_cardev.start()

    p_video.join()
    p_cardev.join()

    p_video.terminate()
    p_cardev.terminate()
